package com.ruoyi.web.controller.order;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.order.domain.GoodsOrderInfo;
import com.ruoyi.order.service.IGoodsOrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 卖品订单信息Controller
 *
 * @author HHAOYU
 * @date 2021-01-16
 */
@RestController
@RequestMapping("/order/goodsOrderInfo")
public class GoodsOrderInfoController extends BaseController
{
    @Autowired
    private IGoodsOrderInfoService goodsOrderInfoService;

    /**
     * 查询卖品订单信息列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:goodsOrderInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(GoodsOrderInfo goodsOrderInfo)
    {
        startPage();
        List<GoodsOrderInfo> list = goodsOrderInfoService.selectGoodsOrderInfoList(goodsOrderInfo);
        return getDataTable(list);
    }

    /**
     * 导出卖品订单信息列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:goodsOrderInfo:export')")
    @Log(title = "卖品订单信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GoodsOrderInfo goodsOrderInfo)
    {
        List<GoodsOrderInfo> list = goodsOrderInfoService.selectGoodsOrderInfoList(goodsOrderInfo);
        ExcelUtil<GoodsOrderInfo> util = new ExcelUtil<GoodsOrderInfo>(GoodsOrderInfo.class);
        return util.exportExcel(list, "goodsOrderInfo");
    }

    /**
     * 获取卖品订单信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:goodsOrderInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(goodsOrderInfoService.selectGoodsOrderInfoById(id));
    }

    /**
     * 新增卖品订单信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:goodsOrderInfo:add')")
    @Log(title = "卖品订单信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GoodsOrderInfo goodsOrderInfo)
    {
        return toAjax(goodsOrderInfoService.insertGoodsOrderInfo(goodsOrderInfo));
    }

    /**
     * 修改卖品订单信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:goodsOrderInfo:edit')")
    @Log(title = "卖品订单信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GoodsOrderInfo goodsOrderInfo)
    {
        return toAjax(goodsOrderInfoService.updateGoodsOrderInfo(goodsOrderInfo));
    }

    /**
     * 删除卖品订单信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:goodsOrderInfo:remove')")
    @Log(title = "卖品订单信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(goodsOrderInfoService.deleteGoodsOrderInfoByIds(ids));
    }
}
